/*********************************************************************
 *
 *  elksip - a multi-platform Sip Phone Server
 *
 *  file: sip_core.c  sip core
 *
 *  Copyright 2011-2013 Elksip team.
 *
 ********************************************************************/

#include <string.h>
#include "sip_inc.h"
#include "sip_core.h"
#include "sip_debug.h"
#include "elk_db.h"
#include "elk_nonce.h"

extern char *elk_version;

static SipCore sipCore;

static char SipServerAgent[64] = "Server: ElkSIP  (x.x.x-(i386/linux))";
int SipCoreInit(void)
{
    elk_log_init();
    memset(&sipCore, 0, sizeof(SipCore));
    sipCore.reg_period = SIP_REG_PERIOD;
    sipCore.UserAgent = strdup("zhang/0.5.2");
    sipCore.Max_Forwards = 70;
    sipCore.realm = strdup("elksip");  
    sipCore.auth = 1;

    snprintf(SipServerAgent, sizeof(SipServerAgent), "Server: ElkSIP  (%s-(i386/linux))", elk_version);

    ELK_DB_Open();
    elk_init_nonce();

    elk_log(LOG_INFO, "SipCoreInit !");
    return 0;
}
int core_Get_Auth(void)
{
    return sipCore.auth;
}
const char * get_version(void)
{   
    return SipServerAgent;
}

int SipCoreUnInit(void)
{
    free(sipCore.UserAgent);
    free(sipCore.realm);
    ELK_DB_Close();
    elk_log_close();
    return 0;
}
